package oop.controller.action.test;

import java.sql.SQLException;

public class EditInfoAction extends AbstractEditAction {

	@Override
	public void performDetail() throws Exception {
		String submit = request.getParameter("ti_submit");
		if ("update".equals(submit)) {
			try {
				test.setName(request.getParameter("ti_name"));
				test.setDescription(request.getParameter("ti_description"));
				test.persist();
				setNextAction("test.view");
			} catch (SQLException ex) {
				if (ex.getErrorCode() == 1062) {
					request.setAttribute("nameErr", "Tên đề thi đã dùng.");
				} else {
					throw ex;
				}
			}
		}
	}

}
